package com.zdp.common;

import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import javax.servlet.http.HttpServletRequest;

/**
 * @author sesshomaru
 * @date 2021/7/28 20:31
 */
@Slf4j
@Component
public class HeadHelper {

    private HttpServletRequest getHttpServletRequest() {
        return ((ServletRequestAttributes) RequestContextHolder.currentRequestAttributes()).getRequest();
    }

    public String getToken() {
        String token = getHttpServletRequest().getHeader("token");
        return token;
    }
}
